<script setup lang="ts">
import { ref } from "vue";
import sheep from "@/sheep";

sheep.$store("app").template.basic.tabbar.list =
  sheep.$store("app").template.basic.tabbar.otherlist;
// 获取公司信息
const companyInfo = ref({
  id: 2,
  name: "测试公司",
  logo: "https://tse4-mm.cn.bing.net/th/id/OIP-C.lhibvaCdwSnTxWVg7ykIkQHaHa?rs=1&pid=ImgDetMain",
  address: "内蒙古",
  legal: "内蒙古",
  //所属行业
  category_id_f: "1",
});

const formData = ref({
  userInfo: {
    name: "张泽宇",
    avatar: "https://img.yzcdn.cn/vant-weapp/avatar-src.jpeg",
    position: "消防第一大队",
  }
});

const navigateToModify = () => {
  uni.navigateTo({
    url: "/pages/other/modifyuser",
  });
};
const singout = () => {
  uni.showModal({
    title: "提示",
    content: "确定退出登录吗？",
    success: (res) => {
      if (res.confirm) {
        console.log("用户点击确定", sheep.$store("user").userInfo);
        // 验证wx_id是否存在
        if (!sheep.$store("user").userInfo?.wx_id) {
          uni.showToast({
            title: "用户信息异常，请重新登录",
            icon: "none",
          });
          return;
        }
        // 调用退出登录接口
        sheep.$api.login
          .login_out({
            wx_id: sheep.$store("user").userInfo.wx_id,
          })
          .then(() => {
            // 清除本地登录状态
            sheep.$store("user").isLogin = false;
            sheep.$store("user").userInfo = {};
            // 跳转到首页
            uni.reLaunch({
              url: "/pages/index/index",
            });
          })
          .catch((err) => {
            console.error("退出登录失败", err);
          });
      }
    },
  });
};
console.log("userInfo11", sheep.$store("user").userInfo);
const navigateToChangePsaaword = () => {
  uni.navigateTo({
    url: "changepwd",
  });
};
</script>

<template>
  <s-layout title="我的" tabbar="/pages/other/user">
    <!-- 页面全局配置 -->
    <view class="pageconfig">
      <!--vuetop-->
      <view class="cu-list card-menu myself">
        <view class="avatar">
          <image class="avatar-img" :src="sheep.$store('user').userInfo.wx_avatarUrl" mode="aspectFit"
            @click="navigateToModify"></image>
          <view class="avatar-massage">
            <view class="top" style="
                display: flex;
                flex-direction: column;
                justify-content: center;
              ">
              <view class="avatar-massage1-border" @click="navigateToModify">
                <view class="avatar-massage1">{{
                  sheep.$store("user").userInfo.tpu_name
                }}</view>
                <!-- <view class="avatar-gengduo">
                  <view class="avatar-gengduo-txt rectangle"> 修改 </view>
                </view> -->
              </view>
            </view>
            <view>
              <view class="avatar-massage4-border">
                <view class="list-item-right-tag">
                  <view class="list-item-right-tag-box">
                    <view class="list-item-right-tag-box-text">
                    </view>
                    <!-- <view class="list-item-right-tag-box-text">联系方式：{{companyInfo.phone }}</view> -->
                    <!-- <view class="list-item-right-tag-box-text">联系方式：12345678997</view> -->
                  </view>
                </view>
              </view>
            </view>
          </view>
        </view>
        <view class="my-content">
          <view>
            <view class="thin-divider"></view>
            <view class="my-content1" @click="navigateToChangePsaaword">
              <image class="my-content-pic" src="@/static/tabs/账号与安全.png" mode="scaleToFill" />
              <view>账号与安全</view>
            </view>
            <view class="thin-divider"></view>
            <view class="thin-divider"></view>
            <view class="my-content1" @click="singout">
              <image class="my-content-pic" src="@/static/tabs/清理缓存.png" mode="scaleToFill" />
              <view>退出登录</view>
            </view>
            <view class="thin-divider"></view>
            <view class="my-content1">
              <image class="my-content-pic" src="@/static/tabs/关于我们.png" mode="scaleToFill" />
              <view>关于我们</view>
            </view>
            <view class="thin-divider"></view>
            <view class="my-content1">
              <image class="my-content-pic" src="@/static/tabs/联系客服.png" mode="scaleToFill" />
              <button open-type="contact" style="
                  background: transparent;
                  border: none;
                  outline: none;
                  padding: 0;
                  margin: 0;

                  /* 清除浏览器默认样式 */
                  -webkit-appearance: none;
                  -moz-appearance: none;
                  appearance: none;

                  /* 清除点击效果 */
                  box-shadow: none;
                  text-shadow: none;

                  /* 文字样式重置（可选） */
                  font-family: inherit;
                  font-size: inherit;
                  color: inherit;
                  line-height: inherit;
                ">
                联系客服
              </button>
            </view>
          </view>
        </view>
      </view>

    </view>
  </s-layout>
</template>

<style lang="scss" scoped>
page {
  height: 100%;
  overflow: hidden;
  background-color: #f0f3f8;
}

.btnStyle {
  display: flex;
  justify-content: start;
  align-items: center;
  margin: 0 50rpx;
  margin-left: -30rpx;
  color: #333;
  font-size: 30rpx;
  height: 110rpx;
}

/**pagedomcss**/

.picture2 {
  width: 100%;
  height: 400rpx;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.myself {
  z-index: 2;
  color: #000;
  margin-top: 10rpx;
}

.avatar {
  margin-top: 10rpx;
  display: flex;
  background: linear-gradient(145deg, rgba(55, 114, 255, 0.9) 0%, rgba(122, 171, 255, 0.9) 50%, rgba(187, 225, 250, 0.9) 100%);
  border-radius: 20rpx;
  height: 165rpx;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(55, 114, 255, 0.2);
}

.avatar-img {
  background-color: #fff;
  height: 100rpx;
  width: 100rpx;
  border-radius: 50%;
  margin-left: 30rpx;
  margin-top: 30rpx;
  margin-right: 20rpx;
  margin-bottom: 20rpx;
  border: 1px solid #999;
  box-shadow: 4rpx 4rpx 12rpx rgba(0, 0, 0, 0.15);
}

.avatar-massage {
  flex: 1;
  margin-top: 20rpx;
  margin-left: 20rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.avatar-massage1 {
  font-size: 30rpx;
  font-weight: 600rpx;
  margin-top: 15rpx;
  margin-bottom: 5rpx;
  color: #fff;
}

.avatar-massage1-border {
  display: flex;
  justify-content: space-between;
}

.avatar-massage1-border:hover {
  transform: translateY(-2px);
}

.avatar-massage3 {
  margin-bottom: 10rpx;
  display: flex;
  justify-content: space-between;
}

.avatar-massage3-left {
  font-size: 26rpx;
  color: #dddedf;
}

.avatar-massage3-right {
  font-size: 26rpx;
  color: #001e7a;
  margin-right: 20rpx;
}

.avatar-massage4-border {
  margin-bottom: 50rpx;
}

.list-item-right-tag-box {
  margin-bottom: 50rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.list-item-right-tag-box-text {
  text-overflow: ellipsis;
  width: 90%;
  font-size: 26rpx;
  font-weight: 550;
  color: #fff;
}

.my-content {
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 20rpx;
  margin-top: 20rpx;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(55, 114, 255, 0.1);
}

.thin-divider {
  height: 1px;
  background-color: rgba(55, 114, 255, 0.1);
  margin: 0 25rpx;
}

.my-content1 {
  display: flex;
  justify-content: start;
  align-items: center;
  margin: 0 50rpx;
  color: #333;
  font-size: 30rpx;
  height: 110rpx;
  transition: all 0.3s ease;

  &:hover {
    transform: translateX(10px);
  }
}

.my-button {
  margin-top: 200rpx;
  width: 50%;
  border-radius: 30rpx;
  height: 70rpx;
  background-color: #0038b1;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 3px 3px 5px rgba(164, 161, 161, 0.5);
}

.button-container {
  display: flex;
  justify-content: center;
}

.my-content-pic {
  width: 50rpx;
  height: 50rpx;
  margin-right: 10rpx;
  z-index: 1;
}

.cu-list {
  width: 92%;
  margin-left: auto;
  margin-right: auto;
  border-radius: 3%;
}

.rectangle {
  padding: 5px 15px;
  background: linear-gradient(135deg, rgba(55, 114, 255, 0.9) 0%, rgba(163, 199, 255, 0.9) 100%);
  color: #fff;
  font-family: 'Segoe UI';
  box-shadow: 0 2px 10px rgba(55, 114, 255, 0.3);
  min-width: 80px;
  text-align: center;
  font-size: 26rpx;
  border-radius: 50px;
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/**修改弹出框 */
.modal-content {
  padding: 40rpx;
  background: #fff;
  border-radius: 24rpx;

  .modal-title {
    font-size: 36rpx;
    font-weight: bold;
    text-align: center;
    margin-bottom: 40rpx;
  }

  .button-group {
    margin-top: 60rpx;
    display: flex;
    justify-content: space-between;
  }
}
</style>
